﻿using Demo.Core.Contracts.Services.Notifications;
using Demo.Core.Contracts.Services.Notifications.Dtos;
using Demo.NotificationManager.Contracts.Services.Notifications;
using Demo.NotificationManager.Contracts.Services.Notifications.Dtos;
using Mapster;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

namespace Demo.Core.Services.Notifications;

public class CoreNotificationAppService:ApplicationService,ICoreNotificationAppService
{
    private readonly INotificationAppService _notificationAppService;

    public CoreNotificationAppService(INotificationAppService notificationAppService)
    {
        _notificationAppService = notificationAppService;
    }

    public async Task<PagedResultDto<CoreNotificationDto>> GetAllAsync(PagedAndSortedResultRequestDto request)
    {
        var ret = await _notificationAppService.GetListAsync(request);
        return new PagedResultDto<CoreNotificationDto>(ret.TotalCount, ret.Items.Adapt<List<CoreNotificationDto>>());
    }

    public async Task<bool> CreatAsync(CoreNotificationCreateDto request)
    {
        var notification = request.Adapt<NotificationDto>();
        await _notificationAppService.CreateAsync(notification);
        return true;
    }
}